home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / debugger / ddd-1.000 / ddd-1 / ddd-1.4b / ddd / header.ps < prev    next >
Encoding:
Text File  |  1995-11-21  |  7.4 KB  |  326 lines

  1. % $Id: header.ps,v 1.2 1995/11/21 13:51:51 zeller Exp $
  2. % Header for NORA PostScript Box output
  3.  
  4. % Copyright (C) 1995 Technische Universitaet Braunschweig, Germany.
  5. % Written by Christian Lindig (lindig@ips.cs.tu-bs.de).
  6. % This file is part of the DDD Library.
  7. % The DDD Library is free software; you can redistribute it and/or
  8. % modify it under the terms of the GNU Library General Public
  9. % License as published by the Free Software Foundation; either
  10. % version 2 of the License, or (at your option) any later version.
  11. % The DDD Library is distributed in the hope that it will be useful,
  12. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. % See the GNU Library General Public License for more details.
  15. % You should have received a copy of the GNU Library General Public
  16. % License along with the DDD Library -- see the file COPYING.LIB.
  17. % If not, write to the Free Software Foundation, Inc.,
  18. % 675 Mass Ave, Cambridge, MA 02139, USA.
  19. % DDD is the data display debugger.
  20. % For details, see the DDD World-Wide-Web page, 
  21. % `http://www.cs.tu-bs.de/softech/ddd/',
  22. % or send a mail to the DDD developers at `ddd@ips.cs.tu-bs.de'.
  23.  
  24. %
  25. % make all definitions local to the noradict dictionary
  26. %
  27.  
  28. /noradict 25 dict def 
  29.  
  30. noradict begin        % make dict active 
  31.  
  32. %
  33. % global variables
  34. %
  35.  
  36. /fontSize+ 12 def
  37. /font+ /Courier def  
  38.  
  39. %
  40. % some small utilities
  41. %
  42.  
  43. /cm { 28.34646 mul } bind def
  44.  
  45. % isolatin1*
  46. % reencode a font to ISO Latin 1 encoding
  47. %
  48. % newfont table oldfont isolatin1*
  49.  
  50. /isolatin1* {
  51.     findfont
  52.     dup maxlength dict begin
  53.     {
  54.         1 index /FID ne { def } { pop pop } ifelse
  55.     } forall
  56.     /Encoding exch def
  57.     dup /FontName exch def
  58.     currentdict end definefont pop
  59. } bind def
  60.  
  61. %
  62. % define the ISO Latin 1 encoding of a font ..
  63. %
  64.  
  65. /isotable[
  66. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  67. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  68. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  69. /.notdef/.notdef/.notdef/.notdef/.notdef/space/exclam/quotedbl/numbersign
  70. /dollar/percent/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma
  71. /hyphen/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
  72. /semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S
  73. /T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore
  74. /quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar
  75. /braceright/asciitilde/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  76. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  77. /.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve/dotaccent/dieresis
  78. /.notdef/ring/cedilla/.notdef/hungarumlaut/ogonek/caron/.notdef/exclamdown/cent
  79. /sterling/currency/yen/brokenbar/section/dieresis/copyright/ordfeminine
  80. /guilsinglleft/logicalnot/hyphen/registered/macron/degree/plusminus/twosuperior
  81. /threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior
  82. /ordmasculine/guilsinglright/onequarter/onehalf/threequarters/questiondown
  83. /Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla/Egrave/Eacute
  84. /Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis/Eth/Ntilde/Ograve
  85. /Oacute/Ocircumflex/Otilde/Odieresis/multiply/Oslash/Ugrave/Uacute/Ucircumflex
  86. /Udieresis/Yacute/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis
  87. /aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave/iacute
  88. /icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis
  89. /divide/oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis
  90. ] def
  91.  
  92. %
  93. % ycorrect*
  94. % the reference point of a string ist NOT its lower left corner but 
  95. % its baseline. Therefor the y coordinate must be corrected. The
  96. % correction for the current font is returned.
  97. % ycorrect* y
  98.  
  99. /ycorrect* {
  100.     currentfont /FontBBox get
  101.     aload pop pop pop
  102.     currentfont /FontMatrix get dtransform
  103.     exch pop
  104. } def 
  105.  
  106. %
  107. % text*
  108. % print out a string and make sure not to require more space than
  109. % specified.
  110. % font xsize ysize xorigin yorigin (string) text*
  111.  
  112. /text* {
  113.  
  114.     /string+ exch def        % set up some variables ..
  115.     moveto                % move to (xorigin,yorigin)
  116.     /ysize+ exch def
  117.     /xsize+ exch def
  118.     /thefont+ exch def
  119.  
  120.     % right font allready selected ?
  121.     
  122.     thefont+ font+ ne 
  123.     ysize+ fontSize+ ne
  124.     or {    
  125.         % set up the right font - reencode it    
  126.         
  127.         /Symbol thefont+ eq 
  128.         {
  129.             thefont+ findfont
  130.         }{
  131.  
  132.             /isofont+ isotable thefont+ isolatin1*    
  133.             /isofont+ findfont
  134.         }ifelse
  135.  
  136.         [ysize+ 0 0 ysize+ neg 0 0] makefont
  137.         setfont
  138.         
  139.         /font+ thefont+ def
  140.         /fontSize+ ysize+ def
  141.     } if
  142.  
  143.     % correct current point 
  144.  
  145.     0 ycorrect* neg rmoveto
  146.  
  147.     % string too long ? scale it down ...
  148.     % the actual font is scaled. There is a good chance,
  149.     % that this will not happen too often when the font is not
  150.     % changed during the calls of text*
  151.  
  152.     xsize+ string+ stringwidth pop div dup dup
  153.     1 lt {
  154.         
  155.         0 0 1 0 0 6 array astore currentfont exch 
  156.         makefont setfont
  157.         pop
  158.     }{ 
  159.         %
  160.         % string too short ... scale it up
  161.         %
  162.  
  163.         1.05 gt {
  164.             0 0 1 0 0 6 array astore currentfont exch 
  165.             makefont setfont    
  166.         }{
  167.             pop
  168.  
  169.         } ifelse
  170.     } ifelse
  171.     
  172.     string+ show
  173.  
  174. } bind def
  175.  
  176.  
  177.     
  178. % arrowline*
  179. % draw a line of given width with an arrow at its end
  180. % len gives the height of the triangle forming the head of the arrow
  181. % and angle the angle at its top
  182. %    
  183. % angle len  x1 y1 x2 y2 linewidth arrowline*
  184. %
  185.  
  186. /arrowline* {
  187.     setlinewidth            % angle len x1 y1 x2 y2
  188.     /y2 exch def
  189.     /x2 exch def
  190.     /y1 exch def
  191.     /x1 exch def
  192.     /len+ exch def            % height of triangle
  193.  
  194.     /alpha+ 
  195.         y2 y1 sub        % define alpha+
  196.         x2 x1 sub
  197.         atan
  198.     def
  199.  
  200.     /base+                % define half of baseline
  201.         exch 
  202.         2 div dup        % angle angle
  203.         sin exch cos          % sin(angle) cos(angle)
  204.         div            % tan(angle)
  205.         len+
  206.         mul            % half of baseline
  207.     def  
  208.     
  209.     newpath                % draw the line
  210.     x1 y1 moveto 
  211.     x2 len+ alpha+ cos mul sub     % shorten the line to the end  
  212.     y2 len+ alpha+ sin mul sub     % of the triangle
  213.     lineto
  214.     stroke        
  215.  
  216.     gsave                % set the origin to the head of
  217.     0 setlinewidth            % the arrow and rotate the system
  218.     x2 y2 
  219.     translate            % origin now at x2 y2
  220.  
  221.     alpha+ 90 sub rotate         % rotate the system
  222.  
  223.     newpath                % draw a triangle
  224.     0 0 moveto
  225.     base+ len+ neg rlineto
  226.     base+ 2 mul neg 0 rlineto
  227.     closepath
  228.     fill
  229.     
  230.     grestore
  231. } bind def
  232.  
  233. % line*
  234. % draw a line of given width from (x1,y1) to (x2,y2)
  235. % x1 y1 x2 y2 width line*
  236. %
  237.  
  238. /line* {
  239.     setlinewidth    % x1 y1 x2 y2
  240.     newpath
  241.     4 2 roll     % x2 y2 x1 y1
  242.     moveto        % x2 y2
  243.     lineto        
  244.     stroke
  245. } bind def
  246.  
  247. %
  248. % clean*
  249. % fill a box given by four points with white colour ..
  250. % x1 y1 x2 y2 x3 y3 x4 y4 clean*
  251. %
  252.  
  253. /clean* {
  254.     gsave
  255.     1 setgray
  256.     0 setlinewidth
  257.     newpath
  258.     moveto  lineto  lineto lineto
  259.     closepath
  260.     fill
  261.     grestore
  262. } bind def
  263.  
  264. %
  265. % box*
  266. % fill a box given by four points
  267. % x1 y1 x2 y2 x3 y3 x4 y4 box*
  268. %
  269.  
  270. /box* {
  271.     0 setlinewidth
  272.     newpath
  273.     moveto     lineto     lineto lineto
  274.     closepath
  275.     fill
  276. } bind def
  277.  
  278. %
  279. % arc*
  280. % draw an ellipse with center (cx,cy), diameter dx dy, starting at start
  281. % and ending at end.
  282. % start end dx dy cx cy width ARC*
  283. %
  284.  
  285. /arc* {
  286.     gsave
  287.     setlinewidth
  288.     translate
  289.     newpath
  290.     dup 3 1 roll        % start end dy dx dy
  291.     div 1 scale        % dy dx/dy 1 scale => start end dy
  292.     
  293.     0 exch  0 exch        % start end 0 0 dy 
  294.     5 -2 roll         % 0 0 dy start end
  295.  
  296.     dup
  297.     0 eq {            % replace 0 by 360
  298.         pop 
  299.         360
  300.     } if
  301.     arc
  302.     stroke
  303.     grestore
  304. } bind def
  305.  
  306.  
  307. %
  308. % set up the right font to the right size
  309. %
  310.  
  311. /isofont+ isotable font+ isolatin1*     % reencode font+
  312.                     % and make it the current font
  313. /isofont+ findfont
  314. [fontSize+ 0 0 fontSize+ neg 0 0] makefont
  315. setfont
  316.  
  317. %%EndProlog
  318.